package mmoon.mmoonstory.items.itemtools;

import mmoon.mmoonstory.MMoonUtils;
import mmoon.mmoonstory.interfaces.InitItem;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;

import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.Set;

public class ItemUniversalTool extends ItemTool implements InitItem {
    public static final String ObjID = "universal_tool";

    public ItemUniversalTool() {
        super(0, Float.MAX_VALUE, MMoonUtils.UNI, new HashSet<>());
        this.init(ObjID);
    }

    @Override
    public float getDestroySpeed(ItemStack stack, IBlockState state) {
        return Float.MAX_VALUE;
    }

    @Override
    public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
        return true;
    }

    @Override
    public int getHarvestLevel(ItemStack stack, String toolClass,
            @javax.annotation.Nullable net.minecraft.entity.player.EntityPlayer player,
            @Nullable IBlockState blockState) {
        return Integer.MAX_VALUE;
    }

    @Override
    public Set<String> getToolClasses(ItemStack stack) {
        HashSet<String> tempSet = new HashSet<>();
        tempSet.add("axe");
        tempSet.add("shovel");
        tempSet.add("pickaxe");
        return tempSet;
    }

    @Override
    public boolean canHarvestBlock(IBlockState blockIn) {
        return true;
    }

    @Override
    public boolean isShield(ItemStack stack, @Nullable EntityLivingBase entity) {
        return entity instanceof EntityPlayer;
    }

    @Override
    public boolean canDisableShield(ItemStack stack, ItemStack shield, EntityLivingBase entity,
            EntityLivingBase attacker) {
        return attacker instanceof EntityPlayer;
    }
}
